package com.jx.lcs.product.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.tianyu.jty.common.persistence.HibernateDao;
import com.tianyu.jty.common.service.BaseService;
import com.jx.lcs.product.dao.ProductTypeDao;
import com.jx.lcs.product.entity.ProductType;

/**
 * 商品类型service
 * @author ty
 * @date 2015年1月22日
 */
@Service
@Transactional(readOnly=true)
public class ProductTypeService extends BaseService<ProductType, String> {
	
	@Autowired
	private ProductTypeDao productTypeDao;

	@Override
	public HibernateDao<ProductType, String> getEntityDao() {
		return productTypeDao;
	}
	
	/**
	 * 根据类型编码获取产品类型
	 * @param typeCode
	 * @return
	 */
	public ProductType findEntityByTypeCode(String typeCode) {
		List<ProductType> list = productTypeDao.findBy("typecode", typeCode);
		ProductType productType = null;
		if(list != null && list.size() > 0) {
			productType = list.get(0);
		}
		return productType;
	}

}
